/*
 * JOAQUÍN RAMÓN ANTÚNEZ SÁNCHEZ
 * 17 de septiembre de 2014
 * 
 */

package mezzo;

import java.util.HashMap;


@SuppressWarnings({"unchecked", "rawtypes"})
public class Decca extends DefaultMezzo{
	
	public Decca(){
		super();
		this.data = new HashMap();
		this.data.put("etiqueta", "");
	}
	
	// propiedades
	public String getEtiqueta(){
		return this.data.get("etiqueta").toString();
	}
	public void setEtiqueta(final String value){
		this.data.put("etiqueta", value.trim().toUpperCase());
	}
	
	@Override
	public String toString(){
		return this.getEtiqueta();
	}
	
	
	public static Decca add(String nombre){
		Decca decca = new Decca();
		decca.setEtiqueta(nombre);
		decca.add();
		
		return decca;
	}
	
	@Override
	public boolean remove(){
		
		return ( 0 !=  mon.jr.exec( String.format(
				"DELETE FROM amadeus.discograficas WHERE id = %d AND " +
				"(select count(id) from amadeus.discos where id_etiqueta = %d) = 0", 
				this.get(), this.get()) ) );
	}
	
}
